home *** CD-ROM | disk | FTP | other *** search
/ Delphi Informant Complete 1995 - 2000 / Delphi Informant Complete 1995 to 2000.iso / Delphi Informant Magazine Complete Works SOURCE CODE 1995.rar / 1995 / AUG / DH9508 / ini_app.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-05  |  3KB  |  101 lines

  1. unit Ini_app;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, IniFiles, ExtCtrls, StdCtrls, Menus, Buttons;
  8.  
  9. type
  10.   TFormSA = class(TForm)
  11.     ListBox1: TListBox;
  12.     Label1: TLabel;
  13.     Button1: TButton;
  14.     Edit1: TEdit;
  15.     BitBtn1: TBitBtn;
  16.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  17.     procedure FormCreate(Sender: TObject);
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure BitBtn1Click(Sender: TObject);
  20.     procedure FormResize(Sender: TObject);
  21.  
  22.   private
  23.     { Private declarations }
  24.   public
  25.     { Public declarations }
  26.   end;
  27.  
  28. var
  29.   FormSA: TFormSA;
  30.  
  31. implementation
  32.  
  33. {$R *.DFM}
  34.  
  35. procedure TFormSA.FormClose(Sender: TObject; var Action: TCloseAction);
  36. var
  37.    TheIni: TIniFile;
  38. begin
  39.    TheIni := TIniFile.Create('SAMPLEAP.INI');
  40.    TheIni.WriteInteger('Settings', 'Top', FormSA.Top);
  41.    TheIni.WriteInteger('Settings', 'Left', FormSA.Left);
  42.    TheIni.WriteInteger('Settings', 'Height', FormSA.Height);
  43.    TheIni.WriteInteger('Settings', 'Width', FormSA.Width);
  44.    TheIni.WriteString('Settings', 'Variable', ListBox1.Items[ListBox1.ItemIndex]);
  45.    TheIni.Free;
  46. end;
  47.  
  48. procedure TFormSA.FormCreate(Sender: TObject);
  49. var
  50.    TheIni: TIniFile;
  51. begin
  52.    TheIni := TIniFile.Create('WIN.INI');
  53.    TheIni.ReadSection('Desktop', ListBox1.Items);
  54.    TheIni.Free;
  55.  
  56.    TheIni := TIniFile.Create('SAMPLEAP.INI');
  57.    FormSA.Top := TheIni.ReadInteger('Settings', 'Top', 0);
  58.    FormSA.Left := TheIni.ReadInteger('Settings', 'Left', 0);
  59.    FormSA.Height := TheIni.ReadInteger('Settings', 'Height', 100);
  60.    FormSA.Width := TheIni.ReadInteger('Settings', 'Width', 100);
  61.    ListBox1.ItemIndex := ListBox1.Items.IndexOf(TheIni.ReadString('Settings', 'Variable', ''));
  62.    TheIni.Free;
  63.  
  64.    FormSA.FormResize(FormSA);
  65. end;
  66.  
  67. procedure TFormSA.Button1Click(Sender: TObject);
  68. var
  69.    TheIni: TIniFile;
  70. begin
  71.    If ListBox1.ItemIndex > -1 then
  72.    begin
  73.       TheIni := TIniFile.Create('WIN.INI');
  74.       Edit1.Text := TheIni.ReadString('Desktop', ListBox1.Items[ListBox1.ItemIndex],'');
  75.       TheIni.Free;
  76.    end;
  77. end;
  78.  
  79. procedure TFormSA.BitBtn1Click(Sender: TObject);
  80. begin
  81.    Close;
  82. end;
  83.  
  84. procedure TFormSA.FormResize(Sender: TObject);
  85. begin
  86.    If FormSA.Width < 250 then FormSA.Width := 250;
  87.    If FormSA.Height < 300 then FormSA.Height := 300;
  88.  
  89.    ListBox1.Height := FormSA.ClientHeight - 179;
  90.    ListBox1.Width := FormSA.ClientWidth - 32;
  91.    Button1.Top := FormSA.ClientHeight - 122;
  92.    Button1.Left := FormSA.ClientWidth div 2 - Button1.Width div 2;
  93.    Edit1.Top := FormSA.ClientHeight - 81;
  94.    Edit1.Width := FormSA.ClientWidth - 32;
  95.    BitBtn1.Top := FormSA.ClientHeight - 40;
  96.    BitBtn1.Left := (FormSA.ClientWidth div 2) - (BitBtn1.Width div 2);
  97.  
  98. end;
  99.  
  100. end.
  101.